﻿<%@ Page Language="C#" MasterPageFile="~/Users/MasterPage.master" AutoEventWireup="true" Inherits="Users_PwdManage" Title="Untitled Page" Codebehind="PwdManage.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script src="../Include/JS/qq.js"></script>
    <script>
    var up=false;
function AlterPwd()
{
    checkPwd();
    if(!up)
    {
        return;
    }
    var O_OPwd=document.getElementById("txtOldPwd");
    if(O_OPwd.value.length<1)
    {
        alert("旧密码不能为空");
        O_OPwd.focus();
        return;
    }
    var O_NPwd1=document.getElementById("txtNewPwd1");
    if(O_NPwd1.value.length<1)
    {
        alert("新密码不能为空");
        O_NPwd1.focus();
        return;
    }
    var o_Npwd2=document.getElementById("txtNewPwd2");
    if(O_NPwd1.value!=o_Npwd2.value)
    {
        alert("两次输入密码不一致");
        o_Npwd2.focus();
        return;
    }    
    Mask();
    document.getElementById("ShoppingCart").innerHTML="<br /><br />数据加载中......<br /><br /><img src='../images/ajax-loader.gif'>";
    document.getElementById("ModifyPwd").href="";
    CallServer("pwd",O_OPwd.value,O_NPwd1.value);
    document.getElementById("ModifyPwd").href="Javascript:AlterPwd()";
    hide();
}
function AlterPwdQuestion()
{
    var question=document.getElementById("MessageTextBox");
    if(question.value.length<1)
    {
        alert("密码提示问题不能为空!");
        question.focus();
        return;
    }
    if(question.length>20)
    {
        alert("问题长度不能超过20");
        question.focus();
        return;
    }
    var answer=document.getElementById("txtAnswer");
    if(answer.value.length<1)
    {
        alert("密码提示问题答案不能为空!");
        answer.focus();
        return;
    }
    if(answer.value.length>20)
    {
        alert("答案请保持在20个字内");
        answer.focus();
        return;
    }
    Mask();
    document.getElementById("ShoppingCart").innerHTML="<br /><br />数据加载中......<br /><br /><img src='../images/ajax-loader.gif'>";
    document.getElementById("ModifyQuestion").href="";
    CallServer("question",question.value,answer.value);
    document.getElementById("ModifyQuestion").href="Javascript:AlterPwdQuestion()";
    hide();
}
function checkPwd()
{
    var O_OPwd=document.getElementById("txtOldPwd");
    if(O_OPwd.value.length>0)
    {
        CheckOldPwd("pwd",O_OPwd.value);
    }    
}
function ShowQuestion()
{
    document.getElementById("QuestionList").style.display="block";
}
function HidQuestion()
{
    document.getElementById("QuestionList").style.display="none";
}
function CheckQuestion(obj)
{
    var lab=obj.parentElement.children[1].innerHTML;
    document.getElementById("MessageTextBox").value=lab;
    HidQuestion();
}
//更新
function CallServer(item,Opwd,Npwd)  
{ 
      arg = item+"|"+Opwd+"|"+Npwd;   
      <%= ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "")%>;   
}   
//验证旧密码


function CheckOldPwd(item,opwd)
{
    arg = item+"|"+opwd;   
    <%= ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "")%>;   
}
 function ReceiveServerData(result)   
 {  
    var dataArray=result.split("|");    
    if(dataArray[0]=="check")
    {
        if(dataArray[1]=="0")
        {
            alert("旧密码不正确!");
            document.getElementById("txtOldPwd").focus();
            return;
        }
        else
        {
            up=true;
        }
    }
    if(dataArray[0]=="pwd")    
    {
        if(dataArray[1]=="11")
        {
            alert("密码修改成功!");
            document.getElementById("txtOldPwd").value="";
            document.getElementById("txtNewPwd1").value="";
            document.getElementById("txtNewPwd2").value="";
        }
        else
        {
            alert("密码修改失败!");
        }
    }
    if(dataArray[0]=="question")    
    {  
        if(dataArray[1]=="1")
        {
            alert("密码提示问题设置成功!");
        }
        else
        {
            alert("密码提示问题设置失败!");
        }
    }
 } 
 function Mask()
{ 
    var div_back = document.getElementById("div_background");
    div_back.style.display = "block"; 
    var iframe_back = document.getElementById("iframe_back");
    iframe_back.style.display = "block";    
    var cart = document.getElementById("ShoppingCart");
    cart.style.display = "block";
    cart.style.position = "absolute";
    var bigImg = document.getElementById("flag");
    var pleft = 0;
    var ptop = 0;
   
    var obj = bigImg.offsetParent;
 
    while(obj.tagName != "BODY")
    {
         pleft = pleft + obj.offsetLeft;
         ptop = ptop + obj.offsetTop;
         obj = obj.offsetParent;
    }
    ptop = ptop + 150;
    cart.style.left = pleft +100+ "px";
    cart.style.top = ptop +"px";
    cart.style.width = 300 + "px";
    cart.style.backgroundColor  = "#ffffff";
}
function hide()
{
  var div_back = document.getElementById("div_background");
    div_back.style.display = "none"; 
     var iframe_back = document.getElementById("iframe_back");
    iframe_back.style.display = "none";     
    var cart = document.getElementById("ShoppingCart");
    cart.style.display = "none";    
}
    </script>

    <div class="r_right">
        <div class="r_title3">
            <h2>
                密码管理</h2>
        </div>
        <h5>
            更改密码</h5>
        <div class="r_kuang1">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="120" align="right">
                        旧密码：</td>
                    <td>
                        <input class="inputbox" id="txtOldPwd" type="password" size="15" name="txtOldPwd" onchange="checkPwd()"
                            ></td>
                </tr>
                <tr>
                    <td align="right">
                        新密码：</td>
                    <td>
                        <input class="inputbox" id="txtNewPwd1" type="password" size="15" name="txtNewPwd1"></td>
                </tr>
                <tr>
                    <td align="right">
                        再次输入新密码：</td>
                    <td>
                        <input class="inputbox" id="txtNewPwd2" type="password" size="15" name="txtNewPwd2"></td>
                </tr>
            </table>
        </div>
        <div class="r_gouwu_button2" id="flag">
            <ul>
                <li><a href="Javascript:AlterPwd()" id="ModifyPwd">更改密码</a></li>
            </ul>
        </div>
        <h5>
            更改密码提示问题</h5>
        <div class="r_kuang1">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="120" align="right">
                        密码提示问题：</td>
                    <td>
                        <input class="inputbox" id="MessageTextBox" style="width: 200px" name="MessageTextBox"
                            onfocusin="ShowQuestion()" value="<%=Question %>">
                        <div class="r_mmqd" style="display: none" id="QuestionList">
                            <ul>
                                <li>
                                    <input class="inputbox" id="RadioButtonList6_0" type="radio" value="你小学的名字是?" name="RadioButtonList6"
                                        onclick="CheckQuestion(this)">
                                    <label for="RadioButtonList6_0">
                                        你小学的名字是?</label></li>
                                <li>
                                    <input class="inputbox" id="RadioButtonList6_1" type="radio" value="你大学所在的城市是?" name="RadioButtonList6"
                                        onclick="CheckQuestion(this)">
                                    <label for="RadioButtonList6_1">
                                        你大学所在的城市是?</label></li>
                                <li>
                                    <input class="inputbox" id="RadioButtonList6_2" type="radio" value="你家乡的邮政编码是?" name="RadioButtonList6"
                                        onclick="CheckQuestion(this)">
                                    <label for="RadioButtonList6_2">
                                        你家乡的邮政编码是?</label></li>
                                <li>
                                    <input class="inputbox" id="RadioButtonList6_3" type="radio" value="你最好的朋友名字是?" name="RadioButtonList6"
                                        onclick="CheckQuestion(this)">
                                    <label for="RadioButtonList6_3">
                                        你最好的朋友名字是?</label></li>
                                <li>
                                    <input class="inputbox" id="RadioButtonList6_4" type="radio" value="你最喜欢的歌星是?" name="RadioButtonList6"
                                        onclick="CheckQuestion(this)">
                                    <label for="RadioButtonList6_4">
                                        你最喜欢的歌星是?</label></li>
                                <li>
                                    <input class="inputbox" id="RadioButtonList6_5" type="radio" value="" name="RadioButtonList6"
                                        onclick="HidQuestion()">
                                    <label for="RadioButtonList6_5">
                                        取消</label></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        密码提示答案：</td>
                    <td>
                        <input class="inputbox" id="txtAnswer" style="width: 200px" name="txtAnswer" onfocusin="HidQuestion()"></td>
                </tr>
            </table>
        </div>
        <div class="r_gouwu_button3">
            <ul>
                <li><a href="Javascript:AlterPwdQuestion()" id="ModifyQuestion">更改密码提示问题</a></li>
            </ul>
        </div>
        <div class="clear">
        </div>
        <div class="r_top_title">
            <a href="#">
                <img src="../images/top.gif" /></a></div>
        <div id="div_background" class="divbackground" onclick="hide();">
        </div>
        <iframe id="iframe_back" class="diviframe" frameborder="0"></iframe>
        <div id="ShoppingCart" style="z-index: 11; display: none">
        </div>
    </div>
</asp:Content>
